<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<% String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<div>
			<form id="ligerForm">
				<div class="fieldset1 tabel_col clearFix">
					<div class="caption">
						<span class="title">基础档案资料</span>
					</div>
					<div class="fieldBox col_33">
						<div class="label">资料名称</div>
						<div class="field">
							<input id="warrantName"  name="warrantName"  value="${entity.warrantName}"  type="text"   class="ui-textbox"  ligerui="width: 160">
							<span class="requiredSymbol">*</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">权证类别</div>
						<div class="field">
							<select id="warrantType"  name="warrantType"  ligerui="width: 160">
									<option value="">请选择</option>
									<c:forEach items="${warrantTypeList}" var="item">
										<option value="${item.key}" >${item.value}</option>
									</c:forEach>
								</select>
							<span class="requiredSymbol">*</span>
						</div>
					</div>
					<%-- <div class="fieldBox col_33">
						<div class="label">归类级别</div>
						<div class="field">
							<select id="arcLevel"  name="arcLevel"  ligerui="width: 160">
									<option value="">请选择</option>
									<c:forEach items="${arcLevelList}" var="item">
										<option value="${item.key}">${item.value}</option>
									</c:forEach>
								</select>
							<span class="requiredSymbol">*</span>
						</div>
					</div> --%>
					<div class="fieldBox col_33">
						<div class="label">状态</div>
						<div class="field">
							<select id="isValid"  name="isValid"  ligerui="width: 160">
									<option value="1">启用</option>
									<option value="0">废弃</option>
								</select>
							<span class="requiredSymbol">*</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">是否电子</div>
						<div class="field">
							<select id="isEle"  name="isEle"  ligerui="width: 160">
									<option value="no" >否</option>
									<option value="yes">是</option>
								</select>
							<span class="requiredSymbol">*</span>
						</div>
					</div>
				<div class="fieldBox col_33">
						<div class="label">电子资料配置编号</div>
						<div class="field">
								<select id="cfgCd"  name="cfgCd"  ligerui="width: 160" >
									<option value="">请选择</option>
									<c:forEach items="${cfgCdList}" var="item">
										<c:choose>
										   <c:when test="${item.CFG_CD == 'PRJ001'}">    
										   		<option value="${item.CFG_CD}">重卡项目合同</option>
										   </c:when>
										   <c:when test="${item.CFG_CD == 'PRJ002'}">    
										   		<option value="${item.CFG_CD}">汽车金融项目合同</option>
										   </c:when>
										   <c:otherwise>  
												<option value="${item.CFG_CD}">${item.CFG_NM}</option>
										   </c:otherwise>
										</c:choose>
									</c:forEach>
								</select>
							<%-- <input id="cfgCd"  name="cfgCd"  value="${entity.cfgCd}"   type="text"   class="ui-textbox" ligerui="width: 160">
							<span class="requiredSymbol">*</span> --%>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">电子资料配置子编号</div>
						<div class="field">
							<%-- <input id="cfgDtlCd"  name="cfgDtlCd"  value="${entity.cfgDtlCd}"  type="text"   class="ui-textbox" ligerui="width: 160">
							<span class="requiredSymbol">*</span> --%>
							<input id="cfgDtlCd" name="cfgDtlCd" data-value=" " placeholder="--请选择--" ltype="combobox" >
						</div>
					</div>
					
					
					
					
				</div>
				
				<div class="btnsBox">
					<span id="saveBtn" class="sq-button sq-button-round" onclick="save();">保存</span>
					<!-- <span id="closeBtn" class="sq-button sq-button-round" onclick="Remove_navTab();">关闭</span> -->
				</div>
			</form>
		</div>
	</div>
	<script type="text/javascript">
		var id="${entity.id}";
		
		$(function() {
			$("#ligerForm").ligerForm({
				validate: true
			});
			if(id !="") {
				liger.get("warrantType").selectValue("${entity.warrantType}");//权证类别
				liger.get("isEle").selectValue("${entity.isEle}");//是否电子
				//liger.get("arcLevel").selectValue("${entity.arcLevel}");//归类级别
				liger.get("isValid").selectValue("${entity.isValid}");
				liger.get("cfgCd").selectValue("${entity.cfgCd}");
				//liger.get("cfgDtlCd").selectValue("${entity.cfgDtlCd}");
			}
			
			$("#cfgDtlCd").ligerComboBox({
				//url:'<%=path%>/archive/arcBscInfo/selectCfgDtlCdList?cfgCd=${entity.cfgCd}',
				valueField: 'cfgDtlCd',
				textField: 'contNm',
				width:150
			});
			
			$("#cfgCd").change(function(){
				setCfgDtlCd(this);
			});
			
			//触发change事件
			$("#cfgCd").trigger("change");
	    });
	
		function setCfgDtlCd(obj){
			if($("#cfgCd").val() == "") {
				liger.get("cfgCd").clear();
				liger.get("cfgCd").setData({});
			}else {
				 $.ajax({
					type: 'post',
					dataType:'json',
					data:{code:$("#cfgCd").val()},
					url: '<%=path%>/archive/arcBscInfo/selectCfgDtlCdList.do',
					success:function(msg){
						 if(msg.success == 1){
							 var obj = liger.get("cfgDtlCd");
							 if(msg.data){
								 obj.setData(msg.data);//设置下拉选项
								 obj.setValue("${entity.cfgDtlCd}");//设置默认值
							 }else{
								 obj.clear();
								 obj.setData({});
							 }
						 }else{
							 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
						 }
					}
				}); 
			}
		}
		
		//保存
		function save(){
			var ligerForm = liger.get("ligerForm");
			if (!ligerForm.valid()) {
				$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
				return false; 
			}
			
			
			var warrantName = $("#warrantName").val();
			if(warrantName == ""){
				$.ligerDialog.SQalert({content: "请填写资料名称",SQ_type: "warning"});
				return false;
			}
			
			var _warrantType = liger.get("warrantType");
			var warrantType = _warrantType.getValue();
			if(!warrantType){
				$.ligerDialog.SQalert({content: "请选择权证类别！",SQ_type: "warning"});
				return false;
			}
			
			var _isEle = liger.get("isEle");
			var isEle = _isEle.getValue();
			if(!isEle){
				$.ligerDialog.SQalert({content: "请选择是否电子！",SQ_type: "warning"});
				return false;
			}
			
			/* if(!liger.get("arcLevel").getValue()){
				$.ligerDialog.SQalert({content: "请选择归类级别！",SQ_type: "warning"});
				return false;
			} */
			
			if(!liger.get("isValid").getValue()){
				$.ligerDialog.SQalert({content: "请选择状态！",SQ_type: "warning"});
				return false;
			}
			var data = ligerForm.getData();//获取表单数据
			//data["warrantType"] = warrantType;
			
		
			var wait_dialog = null;
			
			$.ajax({
				type: 'post',
				dataType: 'json',
				data: data,
				url: '<%=path%>/archive/arcBscInfo/save.do?id='+id,
				beforeSend: function(){
					wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
				},
				success:function(msg){
					wait_dialog.close();
					if(msg.success == 1){
							$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
							if(id == "") {
								Remove_navTab();//新增，关闭当前页面
							}
					}else{
						$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					}
				}
			});
		}
		
	</script>
</body>
</html>